package io.geekidea.boot.test.controller;

import io.geekidea.boot.framework.page.Paging;
import io.geekidea.boot.framework.response.ApiResult;
import io.geekidea.boot.test.query.AppPayOrderQuery;
import io.geekidea.boot.test.service.PayOrderService;
import io.geekidea.boot.test.vo.AppPayOrderVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * App订单 控制器
 *
 * @author geekidea
 * @since 2025-03-26
 */
@Slf4j
@RestController
@Tag(name = "App订单")
@RequestMapping("/app/payOrder")
public class AppPayOrderController {

    @Autowired
    private PayOrderService payOrderService;

    /**
     * 获取App订单详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App订单详情")
    @PostMapping("/getAppPayOrder/{id}")
    public ApiResult<AppPayOrderVo> getAppPayOrder(@PathVariable Long id) {
        log.info("获取App订单详情：{}", id);
        AppPayOrderVo appPayOrderVo = payOrderService.getAppPayOrderById(id);
        return ApiResult.success(appPayOrderVo);
    }

    /**
     * 获取App订单分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App订单分页列表")
    @PostMapping("/getAppPayOrderPage")
    public ApiResult<AppPayOrderVo> getAppPayOrderPage(@Valid @RequestBody AppPayOrderQuery query) {
        log.info("获取App订单分页列表：{}", query);
        Paging<AppPayOrderVo> paging = payOrderService.getAppPayOrderPage(query);
        return ApiResult.success(paging);
    }

}
